define(['text!evaluate/appraise.html'],
	function(viewTemplate) {
		return Piece.View.extend({
			id: 'evaluate_appraise',
			events: {
//				"click .fa-2x": "iss",
				"click .evt-rate": "rate",
				"click #gotoGift": "gotoGift"
			},
			render: function() {
				$(this.el).html(viewTemplate);

				Piece.View.prototype.render.call(this);
				return this;
			},

			onShow: function() {
				//write your business logic here :)


				var windowHeight = $(window).height();
				console.info("windowHeight="+windowHeight);
				// var elTop = $("#appraise").offset().top;

				// console.info(elTop);
				var elHeight = windowHeight - 43;
				$("#appraise-page").css({
//					"height": 1200
//					"height": elHeight
				});
//				new iScroll($("#appraise"));
//				new iScroll('appraise-page');


			},
            rate: function(el){
//                el.currentTarget
                var target = $(el.currentTarget);
                //console.log("rate this.index="+target.index());
                //console.log("rate this.parent="+target.parent());
                var rv = target.index()+1;
                var items =target.parent().children();
                console.debug('items='+items.length);
                for (var i=0;i<items.length;i++){
                    $(items[i]).removeClass('fa-star');
                    $(items[i]).addClass('fa-star-o');
                }

                for (var i=0;i<rv;i++){
                    $(items[i]).addClass('fa-star');
                    $(items[i]).removeClass('fa-star-o');
                }


//                target.parent
            },
			iss: function(el) {
				var $target = $(el.currentTarget);
				var parent = $($target).parent();

				console.info(parent);
				if ($($target).hasClass("appraise5")) {

				}
			},
			gotoGift: function() {
				this.container.navigateForResult('/evaluate/gift', {
					trigger: true
				}, 'evaluate/appraise', this.onGotResult);
			}
		}); //view define

	});